#!/bin/sh

# step1. 配置参数
TYPE5G="$0"

cd /data/xgz/auto-npm-compile

rm -rf com.nokia.do.ui.framework
rm -rf dist
git clone -q git@192.168.3.137:deepocean/framework/ui/com.nokia.do.ui.framework.git
mv node_modules_temp com.nokia.do.ui.framework/node_modules
cd com.nokia.do.ui.framework/src
mkdir components views

cd components
git clone -q git@192.168.3.137:deepocean/framework/ui/com.nokia.do.ui.sys.components.git
git clone -q git@192.168.3.137:deepocean/framework/ui/com.nokia.do.ui.sys.layout.git
# git clone git@192.168.3.137:deepocean/framework/ui/com.nokia.do.ui.sys.demo.git

# 修改菜单
cd com.nokia.do.ui.sys.layout
rm -rf menu.vue
if [ $TYPE5G != "sa" ];then
   mv menu_prod.vue menu.vue
   echo "菜单替换为NSA"
else
   echo "菜单替换为SA"
   mv menu_prodSA.vue menu.vue
fi

cd ../../views/
# 李梦伟、王基帅
git clone -q git@192.168.3.137:deepocean/framework/ui/com.nokia.do.ui.views.system.git
#端到端定界
git clone -q git@192.168.3.137:deepocean/products/5g/do-for-5g-common/residentanalysis/modules/com.nokia.do.ui.views.biz.5g.residentanalysis.git
#网络监控
git clone -q git@192.168.3.137:deepocean/products/5g/do-for-5g-common/network-monitor/modules/com.nokia.do.ui.views.biz.5g.networkmonitor.git
#网络视图
git clone -q git@192.168.3.137:deepocean/products/5g/do-for-5g-common/netview/com.nokia.do.ui.views.biz.5g.networkview.git
#共建共享
git clone -q git@192.168.3.137:deepocean/products/5g/do-for-5g-common/networkgeneral/modules/com.nokia.do.ui.views.biz.5g.sharebuild.git
# 徐国忠
git clone -q git@192.168.3.137:deepocean/products/5g/do-for-5g-common/5GServiceAnalysis/modules/com.nokia.do.ui.views.biz.5g.serviceanalysis.git
git clone -q git@192.168.3.137:deepocean/products/5g/do-for-5g-common/terminal-analyze/modules/com.nokia.do.ui.views.biz.5g.terminalanalysis.git
# 尹君
git clone  -q git@192.168.3.137:deepocean/products/5g/do-for-5g-common/residentdelimitation/modules/com.nokia.do.ui.views.biz.5g.residentdelimitation.git
# 李力博
git clone -q git@192.168.3.137:deepocean/products/5g/do-for-5g-common/anchorpoint/modules/com.nokia.do.ui.views.biz.5g.anchorpoint.git
git clone -q git@192.168.3.137:deepocean/products/5g/do-for-5g-common/sanetworkview/modules/com.nokia.do.ui.views.biz.5g.sa.networkview.git
# 唐培
git clone -q git@192.168.3.137:deepocean/products/5g/do-for-5g-common/samanageview/modules/com.nokia.do.ui.views.biz.5g.samanageview.git
# 秦金雷（终端分析SA）
git clone -q git@192.168.3.137:deepocean/products/5g/do-for-5g-common/saterminalanalysis/modules/com.nokia.do.ui.views.biz.5g.terminalanalysis.sa.git

# 李力博（切片分析SA）
git clone -q git@192.168.3.137:deepocean/products/5g/do-for-5g-common/saslices/modules/com.nokia.do.ui.views.biz.5g.sa.slices.git

# 切片定界
git clone -q git@192.168.3.137:deepocean/products/5g/do-for-5g-common/slicedelimitation/modules/com.nokia.do.ui.views.biz.5g.sa.slicedelimitation.git

cd ../..
npm i
npm run build
cd ..

if [ $TYPE5G != "sa" ];then
    echo "文件移动到NSA目录"
    rm -rf /data/docker/nginx/www/*
    rm -rf /data/docker/nginxs/nginx81/www/*
    # rm -rf /data/docker/nginxs/nginx9901/www/*
    # rm -rf /data/docker/nginxs/nginx9902/www/*

    \cp com.nokia.do.ui.framework/dist/* /data/docker/nginx/www -rf
    \cp com.nokia.do.ui.framework/dist/* /data/docker/nginxs/nginx81/www -rf
    # \cp com.nokia.do.ui.framework/dist/* /data/docker/nginxs/nginx9901/www -rf
    # \cp com.nokia.do.ui.framework/dist/* /data/docker/nginxs/nginx9902/www -rf
else
    echo "文件移动到SA目录"
    rm -rf /data/docker/nginxs/nginx82/www/*
    \cp com.nokia.do.ui.framework/dist/* /data/docker/nginxs/nginx82/www -rf
fi


mv com.nokia.do.ui.framework/node_modules node_modules_temp
mv com.nokia.do.ui.framework/dist dist
rm -rf com.nokia.do.ui.framework


rm -rf ./dist.tar.gz
tar -czf dist.tar.gz dist/*
wget -q https://gitee.com/xuguozhong/auto-complie/raw/master/utils/send-mail.py
python3 send-mail.py jfjqjljpomyxbidi 前端应用 dist.tar.gz
rm -rf send-mail.py
rm -rf ./dist.tar.gz

if [ $TYPE5G != "sa" ];then
    docker restart ng ng81 # ng9901 ng9902
else
    docker restart nginx82-sa
fi

